<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>杨辉三角</title>
    <script type="text/javascript">
        function demo(x,y){
            // 实现杨辉三角
            if(y==0){
                return 1;
            }else if(x==y){
                return 1;
            }else{
                return demo(x-1,y-1)+demo(x-1,y)
            }
        }
        function comeTrue(y){
            for(var i=0;i<y;i++){
                for(var j=0;j<=i;j++){
                    document.write(demo(i,j)+' ');
                }
                document.write("<br />");
            }
        }
    </script>
</head>
<body>
    <input type="button" value="实现杨辉三角" onclick="comeTrue(12);">
</body>
</html>